/**
 * 
 */
package com.cqan.account.entity.resp;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;

import org.apache.commons.beanutils.BeanUtils;

import com.cqan.account.entity.User;
import com.cqan.util.encode.EncodeUtils;

/**
 * @Description 返回用户基本信息
 * @author slaton.wu@gmail.com
 * @date 2012-7-5下午12:37:09
 *
 */
public class UserResp {

	private Long id;
	
	private String address;
	
	private Date createTime;
	
	private String email;
	
	private boolean enabled;
	
	private Date lastLoginTime;
	
	private String nickname;
	
	private String password;
	
	private String phone;
	
	private String realName;
	
	private String regIp;
	
	private String username;
	
	private String lastLoginIp;
	
	private String token;
	
	/**
	 * 性别
	 */
	private String sex;
	
	/**
	 * 用户级别，0:未注册用户，1:注册用户，2:绑写手机用户
	 */
    private Integer userGrade;
    
    /**
     * 用户头像
     */
    private String avatar;
	
	/**
	 * 是否为管理员
	 */
	private boolean special;
	
	//生日
	private Date birthday;
	
	//学历
	private String degree;

	
	
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getDegree() {
		return degree;
	}

	public void setDegree(String degree) {
		this.degree = degree;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Integer getUserGrade() {
		return userGrade;
	}

	public void setUserGrade(Integer userGrade) {
		this.userGrade = userGrade;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public boolean isSpecial() {
		return special;
	}

	public void setSpecial(boolean special) {
		this.special = special;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getLastLoginIp() {
		return lastLoginIp;
	}

	public void setLastLoginIp(String lastLoginIp) {
		this.lastLoginIp = lastLoginIp;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getRegIp() {
		return regIp;
	}

	public void setRegIp(String regIp) {
		this.regIp = regIp;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}
	
	public void setUserResp(User user){
		try {
			BeanUtils.copyProperties(this, user);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}
	
	public void setUserToken(User user){
		this.token = EncodeUtils.md5(user.getId()+user.getUsername(), user.getPassword());
	}
	
}
